/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : MadMinScore.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Feb 12, 2009  Raghu Sarraff	 		        Created
 */
package lwf.handler.entities.math;

import java.util.List;

import net.lwf.number.util.NumberFormatter;

import lwf.handler.entities.Score;

public class MadMinScore extends Score {
	
	private List data;
	
	public MadMinScore(List sumdata) {
		this.processResults(sumdata);
	}
	
	private void processResults(List sumdata) {
		if(sumdata != null && sumdata.size() != 0) {
			for(int i=0; i<sumdata.size(); i++) {
				MadMinSum sum = (MadMinSum) sumdata.get(i);
				if(sum.getIsCorrect()) {
					addCorrectQ();
				}
				else {
					addWrongQ();
				}
			}
		}
		setData(sumdata);
	}

	/**
	 * @return Returns the percentage.
	 */
	public String getPercentage() {
		double correctanswers = getCorrectQs1();
		double wronganswers = getWrongQs1();
		double percentage = (correctanswers/(correctanswers+wronganswers)) * 100;
		return NumberFormatter.format(String.valueOf(percentage), "#.##"); 
	}
}

